package com.aier.bean.invoice;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.*;

public class Test {
    public static void main(String[] args) throws ClassNotFoundException {
        String templateFileName = "C:\\Users\\15549\\Desktop\\test\\hengda_template1111.xlsx";


        String fileName = "C:\\Users\\15549\\Desktop\\test\\" + System.currentTimeMillis() + ".xlsx";

        /*// 1.创建write
        ExcelWriter excelWriter = EasyExcel.write(fileName)
                .withTemplate(templateFileName)
                .build();
        // 2.创建sheet
        WriteSheet writeSheet = EasyExcel.writerSheet()
                .sheetNo(0)
                .build();*/
        Mark mark = new Mark();
        mark.setFbaCode("哈哈哈哈");
        mark.setPerBoxQty(BigDecimal.valueOf(6666));

        /*Class<?> clazz = mark.getClass();
        Field[] declaredFields = clazz.getDeclaredFields();
        Map<String,Object> map = new HashMap<>();
        Arrays.stream(declaredFields).forEach(field->{
            try {
                map.put(field.getName(),field.get(mark));
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        });*/
        EasyExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(mark);
        /*// 4.填充数据
        excelWriter.fill(map, writeSheet);
        // 5.关闭流
        excelWriter.finish();*/
    }
}
